<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Chat extends CI_Controller {


	function __construct()
	{
		parent::__construct();

		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');
		$this->load->database();

	}

	function index()
	{
		$key = md5('pop_meng123');

		$data['key'] = $key;

		$chat_data = $this->db->get('test.chat');


		$data['chat_data'] = $chat_data->result();

		//$this->load->view('chat/chat_view',$data);
		$this->load->view('chat/chat_view_new',$data);

	}

	function insert()
	{

		$datetime = date('Y-m-d H:i:s');
echo $_POST['name'];
exit;
		$data = array(
               'name' => $_POST['name'],
               'content' => $_POST['content'],
               'time' => $datetime
            );

		$config = array(
               array(
                     'field'   => 'content',
                     'label'   => '发言',
                     'rules'   => 'trim|required|xss_clean'
					),
            );
		$this->form_validation->set_rules($config);

		if ($this->form_validation->run() == FALSE)
		{
			echo 1;
		}
		else
		{
			$this->db->insert('test.chat', $data);
			echo 2;


		}
	}



}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */